package org.hcyspartnoc.luoxin.controller.assessment;

import jakarta.annotation.Resource;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.hcyspartnoc.luoxin.common.core.AjaxResult;
import org.hcyspartnoc.luoxin.common.core.annotation.Log;
import org.hcyspartnoc.luoxin.common.core.annotation.PreAuthorize;
import org.hcyspartnoc.luoxin.common.core.enums.BusinessType;
import org.hcyspartnoc.luoxin.service.assessment.IAssessmentQuestionService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/assessment/question")
public class AssessmentQuestionController {
    @Resource
    private IAssessmentQuestionService assessmentQuestionService;


    @Log(title = "测评·问题·查询·formId", businessType = BusinessType.OTHER)
    @PreAuthorize(auth = "assessment:question:query:formId", descr = "通过测评表id获取问题")
    @GetMapping("/query/{formId:\\d+}")
    public AjaxResult queryByFormId(@PathVariable("formId") Integer formId) {
        assessmentQuestionService.queryByFormId(formId);
        TestVo testVo = new TestVo();
        testVo.setScore(new TestVo.Score(100, 80));
        testVo.setName("nihao").setAge(18);
        return AjaxResult.success(testVo);
    }

    @Data
    @Accessors(chain = true)
    @NoArgsConstructor
    public static class TestVo {
        private Score score;
        private String name;
        private Integer age;

        @Data
        @NoArgsConstructor
        @AllArgsConstructor
        public static class Score {
            private Integer total;
            private Integer origin;
        }
    }
}
